package com.hzit.bj1804.dianservice.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hzit.bj1804.dian.entity.Diaryinfo;
import com.hzit.bj1804.dian.vo.MemberPage;
import com.hzit.bj1804.dianservice.dao.DiaryinfoDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
@Service
public class DiaryinfoServiceImpl implements DiaryinfoService {
    @Autowired
    DiaryinfoDAO diaryinfoDAO;

    /**
     * 分页查询所有
     * @param limit
     * @param page
     * @return
     */
    @Override
    public PageInfo<Diaryinfo> seleAllPage(@RequestParam("limit") int limit, @RequestParam("page") int page) {
        MemberPage memberPage = new MemberPage();
        memberPage.setLimit(limit);
        memberPage.setPage(page);
        PageHelper.startPage(memberPage.getPage(), memberPage.getLimit());
        List<Diaryinfo> diaryinfos = diaryinfoDAO.seleteAll();
        return new PageInfo<>(diaryinfos);
    }

    @Override
    /**
     * 查询所有
     */
    public List<Diaryinfo> seleAll() {
        return diaryinfoDAO.seleteAll();
    }

    @Override
    /**
     * 添加登陆日志
     */
    public int insert(@RequestBody Diaryinfo diaryinfo) {
        return diaryinfoDAO.insertSelective(diaryinfo);
    }
}
